<template>
  <div class="wrapper" @click="handleClick()">
    <div class="candles">
      <!-- <div class="light__wave"></div> -->
      <div :class="['candle1', { candle1_animation: isClick }]">
        <div class="candle1__body">
          <div class="candle1__eyes">
            <span class="candle1__eyes-one"></span>
            <span class="candle1__eyes-two"></span>
          </div>
          <div class="candle1__mouth"></div>
        </div>
        <div class="candle1__stick"></div>
      </div>

      <div :class="['candle2', { candle2_animation: isClick }]">
        <div class="candle2__body">
          <div class="candle2__eyes">
            <div class="candle2__eyes-one"></div>
            <div class="candle2__eyes-two"></div>
          </div>
        </div>
        <div class="candle2__stick"></div>
        <div v-if="!isDark" class="candle2__fire"></div>
      </div>

      <div class="sparkles-one"></div>
      <div class="sparkles-two"></div>
      <div class="candle__smoke-one"></div>
      <div class="candle__smoke-two"></div>
    </div>
    <div class="floor"></div>
  </div>
</template>

<script>
import { reactive, ref, getCurrentInstance } from 'vue'

export default {
  setup(props, context) {
    const isClick = ref(false)
    const isDark = ref(false)
    function handleClick() {
      isClick.value = true
      setTimeout(() => {
        isClick.value = false
        isDark.value = !isDark.value
        context.emit('handleClick', isDark)
      }, 500)
    }
    return { handleClick, isClick, isDark }
  }
}
</script>

<style lang="scss" scoped>
.wrapper {
  position: fixed;
  width: 200px;
  height: 200px;
  right: 0;
  bottom: 0%;
//   transform: scale(1.5, 1.5) translate(-50%, -50%);
  //   background: cadetblue;
}

.floor {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100px;
  height: 5px;
  background: #673c63;
  transform: translate(-50%, -50%);
  box-shadow: 0px 2px 5px #111;
  z-index: 2;
}

.candles {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 250px;
  height: 150px;
  transform: translate(-50%, -100%);
  z-index: 1;
}

.candle1 {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 35px;
  height: 100px;
  background: #fff;
  border: 3px solid #673c63;
  border-bottom: 0px;
  border-radius: 3px;
  transform-origin: center right;
  transform: translate(60%, -25%);
  box-shadow: -2px 0px 0px #95c6f2 inset;

  &__eyes-one {
    position: absolute;
    left: 30%;
    top: 20%;
    width: 5px;
    height: 5px;
    border-radius: 100%;
    background: #673c63;
    transform: translate(-70%, 0%);
  }

  &__eyes-two {
    position: absolute;
    left: 70%;
    top: 20%;
    width: 5px;
    height: 5px;
    border-radius: 100%;
    background: #673c63;
    transform: translate(-70%, 0%);
  }

  &__mouth {
    position: absolute;
    left: 40%;
    top: 20%;
    width: 0px;
    height: 0px;
    border-radius: 20px;
    background: #673c63;
    transform: translate(-50%, -50%);
  }
}
.candle1_animation {
  animation: expand-body 2s infinite linear;

  .candle1__eyes-one,
  .candle1__eyes-two {
    animation: blink-eyes 2s infinite linear;
  }
  .candle1__mouth {
    animation: uff 2s infinite linear;
  }
}

.candle1__stick,
.candle2__stick {
  position: absolute;
  left: 50%;
  top: 0%;
  width: 3px;
  height: 15px;
  background: #673c63;
  border-radius: 8px;
  transform: translate(-50%, -100%);
}
.candle1__eyes,
.candle2__eyes {
  position: absolute;
  left: 50%;
  top: 0%;
  width: 35px;
  height: 30px;
  transform: translate(-50%, 0%);
}

.candle__smoke-one {
  position: absolute;
  left: 30%;
  top: 50%;
  width: 30px;
  height: 3px;
  background: grey;
  transform: translate(-50%, -50%);
  animation: move-left 3s infinite linear;
}

.candle__smoke-two {
  position: absolute;
  left: 30%;
  top: 40%;
  width: 10px;
  height: 10px;
  border-radius: 10px;
  background: grey;
  transform: translate(-50%, -50%);
  animation: move-top 3s infinite linear;
}

.candle2 {
  position: absolute;
  left: 20%;
  top: 65%;
  width: 42px;
  height: 60px;
  background: #fff;
  border: 3px solid #673c63;
  border-bottom: 0px;
  border-radius: 3px;
  transform: translate(60%, -15%);
  transform-origin: center right;
  box-shadow: -2px 0px 0px #95c6f2 inset;
  /* animation: shake-left 1s infinite linear; */

  &__stick {
    height: 12px;
    transform-origin: bottom center;
    /* animation: stick-animation 3s infinite linear; */
  }
  &__eyes-one {
    position: absolute;
    left: 30%;
    top: 50%;
    width: 5px;
    height: 5px;
    display: inline-block;
    border: 0px solid #673c63;
    border-radius: 100%;
    float: left;
    background: #673c63;
    transform: translate(-80%, 0%);
  }
  &__eyes-two {
    position: absolute;
    left: 70%;
    top: 50%;
    width: 5px;
    height: 5px;
    display: inline-block;
    border: 0px solid #673c63;
    border-radius: 100%;
    float: left;
    background: #673c63;
    transform: translate(-80%, 0%);
  }
  &__fire {
    position: absolute;
    top: -36%;
    left: 50%;
    display: block;
    width: 16px;
    height: 20px;
    background-color: red;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: #ff9800;
    transform: translate(-50%, -50%);
  }
}
.candle2_animation {
  animation: shake-left 2s infinite linear;
  .candle2__eyes-one {
    animation: changeto-lower 2s infinite linear;
  }
  .candle2__eyes-two {
    animation: changeto-greater 2s infinite linear;
  }
  .candle2__fire {
    animation: dance-fire 2s infinite linear;
  }
}
.light__wave {
  position: absolute;
  top: 35%;
  left: 35%;
  width: 75px;
  height: 75px;
  border-radius: 100%;
  z-index: 0;
  transform: translate(-25%, -50%) scale(2.5, 2.5);
  border: 2px solid rgba(255, 255, 255, 0.2);
  animation: expand-light 3s infinite linear;
}

@keyframes blink-eyes {
  0% {
    opacity: 1;
    transform: translate(-70%, 0%);
  }
  1%,
  4% {
    opacity: 0;
    transform: translate(-70%, 0%);
  }
  5% {
    opacity: 1;
    transform: translate(-70%, 0%);
  }
  15%,
  20% {
    transform: translate(-140%, 0%);
  }
  41% {
    transform: translate(-70%, 0%);
  }
}
@keyframes expand-body {
  5% {
    transform: scale(1, 1) translate(60%, -25%);
  }
  10%,
  20% {
    transform: scale(1.1, 1.1) translate(60%, -28%);
  }
  25% {
    transform: scale(0.89, 0.89) translate(60%, -25%);
  }
  40% {
    transform: scale(1, 1) translate(60%, -25%);
  }
  45% {
    transform: scale(0.95, 0.95) translate(60%, -25%);
  }
  50% {
    transform: scale(1, 1) translate(60%, -25%);
  }
}
@keyframes uff {
  5% {
    width: 0px;
    height: 0px;
  }
  10%,
  20% {
    width: 15px;
    height: 15px;
    left: 30%;
  }
  24% {
    width: 5px;
    height: 5px;
    left: 20%;
  }
  37% {
    width: 2px;
    height: 2px;
    left: 20%;
  }
  42% {
    width: 0px;
    height: 0px;
    left: 30%;
  }
}
@keyframes change-background {
  0%,
  59%,
  98%,
  100% {
    background: #fef4ad;
  }
  61%,
  97% {
    background: #f8ae39;
  }
}
@keyframes move-left {
  0%,
  59%,
  100% {
    width: 0px;
    left: 40%;
  }
  60% {
    width: 30px;
    left: 30%;
  }
  68% {
    width: 0px;
    left: 20%;
  }
}
@keyframes move-top {
  0%,
  64%,
  100% {
    width: 0px;
    height: 0px;
    top: 0%;
  }
  65% {
    width: 10px;
    height: 10px;
    top: 40%;
    left: 40%;
  }
  80% {
    width: 0px;
    height: 0px;
    top: 20%;
  }
}
@keyframes shake-left {
  //   0% {
  //     left: 20%;
  //     transform: translate(60%, -15%);
  //   }
  //   62% {
  //     left: 18%;
  //     transform: translate(60%, -15%);
  //   }
  //   65% {
  //     left: 21%;
  //     transform: translate(60%, -15%);
  //   }
  //   67% {
  //     left: 20%;
  //     transform: translate(60%, -15%);
  //   }
  5% {
    left: 20%;
    transform: scale(1.15, 0.85) translate(60%, -15%);
    background: #fff;
    border-color: #673c63;
  }
  10%,
  20% {
    left: 20%;
    transform: scale(1.18, 0.82) translate(60%, -10%);
    background: #f44336;
    border-color: #f44336;
    box-shadow: -2px 0px 0px #f44336 inset;
  }
  21% {
    left: 20%;
    transform: scale(0.85, 1.15) translate(60%, -15%);
  }
  25% {
    left: 20%;
    transform: scale(1.05, 0.95) translate(60%, -15%);
  }
  30% {
    left: 20%;
    transform: scale(1, 1) translate(60%, -15%);
  }
}
@keyframes stick-animation {
  0%,
  40% {
    left: 50%;
    top: 0%;
    transform: translate(-50%, -100%);
  }
  50%,
  54% {
    left: 50%;
    top: 0%;
    transform: translate(-50%, -100%);
  }
  59% {
    left: 50%;
    top: 0%;
    transform: translate(-50%, -100%);
  }
  62% {
    left: 50%;
    top: 0%;
    transform: rotateZ(-15deg) translate(-50%, -100%);
  }
  65% {
    left: 50%;
    top: 0%;
    transform: rotateZ(15deg) translate(-50%, -100%);
  }
  70% {
    left: 50%;
    top: 0%;
    transform: rotateZ(-5deg) translate(-50%, -100%);
  }
  72% {
    left: 50%;
    top: 0%;
    transform: rotateZ(5deg) translate(-50%, -100%);
  }
  74%,
  84% {
    left: 50%;
    top: 0%;
    transform: rotateZ(0deg) translate(-50%, -100%);
  }
  85% {
    transform: rotateZ(180deg) translate(0%, 120%);
  }
  92% {
    left: 50%;
    top: 0%;
    transform: translate(-50%, -100%);
  }
}
@keyframes expand-light {
  10%,
  29%,
  59%,
  89% {
    transform: translate(-25%, -50%) scale(0, 0);
    border: 2px solid rgba(255, 255, 255, 0);
  }
  90%,
  20%,
  50% {
    transform: translate(-25%, -50%) scale(1, 1);
  }
  95%,
  96%,
  26%,
  27%,
  56%,
  57% {
    transform: translate(-25%, -50%) scale(2, 2);
    border: 2px solid rgba(255, 255, 255, 0.5);
  }
  0%,
  28%,
  58%,
  100% {
    transform: translate(-25%, -50%) scale(2.5, 2.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
  }
}
@keyframes dance-fire {
  59%,
  89% {
    left: 50%;
    width: 0px;
    height: 0px;
  }
  90%,
  0%,
  7%,
  15%,
  23%,
  31%,
  39%,
  47%,
  55% {
    left: 50.8%;
    width: 16px;
    height: 20px;
    background: #ffc107;
  }
  94%,
  3%,
  11%,
  19%,
  27%,
  35%,
  43%,
  51%,
  58% {
    left: 51.2%;
    width: 16px;
    height: 20px;
    background: #ff9800;
  }
}
@keyframes changeto-lower {
  0%,
  10%,
  30% {
    padding: 0px;
    display: inline-block;
    border-radius: 100%;
    background: #673c63;
    border-width: 0 0 0 0;
    border: 0px solid #673c63;
    transform: translate(-90%, 0%);
  }
  11%,
  29% {
    background: none;
    border: solid #673c63;
    border-radius: 0px;
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 1px;
    float: left;
    transform-origin: bottom left;
    transform: rotate(-45deg) translate(-50%, -65%);
    -webkit-transform: rotate(-45deg) translate(-50%, -65%);
  }
}
@keyframes changeto-greater {
  0%,
  10%,
  30% {
    top: 50%;
    padding: 0px;
    display: inline-block;
    border-radius: 100%;
    background: #673c63;
    border-width: 0 0 0 0;
    border: 0px solid #673c63;
    transform: translate(-80%, 0%);
  }
  11%,
  29% {
    top: 30%;
    background: none;
    border: solid #673c63;
    border-radius: 0px;
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 1px;
    float: left;
    transform-origin: bottom left;
    transform: rotate(135deg) translate(-80%, 20%);
    -webkit-transform: rotate(135deg) translate(-80%, 20%);
  }
}
</style>
